﻿#ifndef CHATSOCKET_H
#define CHATSOCKET_H

#include <QObject>
#include <QTcpSocket>
#include <QHostAddress>
#include <QJsonDocument>
#include <QJsonParseError>
#include <QFile>
#include <QJsonObject>
#include <QDebug>
#include <QJsonArray>
#include <QTime>
class ChatSocket : public QObject
{
    Q_OBJECT
public:
    explicit ChatSocket(QObject *parent = nullptr);
    void checkConnect();
    void sendLogin(unsigned int id,QString username,QString password);  //示例
    void getFriendList(unsigned int id);    //请求好友列表
    void sendMessage(QString message,int send_id, int recv_id); //发送聊天消息
    void getVerifyCode(QString mail);   //获取验证码
    void registerRequest(QString icon,QString user_name,QString pwd,QString real_name,QString address,QString email,QString verify);
private:
    QTcpSocket* client_socket;  //客户端套接字
signals:
    void logonSuccess(int id,QString username,QString icon);
    void logonFailed();
    void friendListSucc(QJsonObject root);  //好友列表响应
    void chatDataPrivate(QJsonObject root); //私聊消息
    void registerRpt(QJsonObject root); //注册结果

private slots:


public slots:
    void slotConnectToServer(QString ip,unsigned int port);
    void slotRecv();
};

#endif // CHATSOCKET_H
